package com.wing.cabinet.model.response;

import com.wing.cabinet.model.entity.UseInventoryKnife;
import com.wing.cabinet.utils.ExcelExport;
import com.wing.product.model.entity.ProductDetail;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 刀具在用库存VO
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class UseInventoryKnifeVO implements Comparable<UseInventoryKnifeVO>{

    /**
     * ID
     */
    private Long id;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime createTime;

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * 库存数量
     */
    private Integer quantity;

    /**
     * 企业id
     */
    private Long companyId;

    /**
     * 货道id
     */
    private Integer spaceId;

    /**
     * (0正常，1告警)
     */
    private Long status;

    /**
     * sku code
     */
    private String skuCode;

    /**
     * 柜子编码
     */
    private String cabCode;

    /**
     * 货道
     */
    private String spaceCode;

    /**
     * 设备编号
     */
    private String deviceCode;

    /**
     * 领新id
     */
    private Long cellInventoryInoutId;

    /**
     * 领新订单编号
     */
    private String orderCode;

    /**
     * useInventoryInoutId
     */
    private Long useInventoryInoutId;

    /**
     * useInventoryInoutDetailId
     */
    private Long useInventoryInoutDetailId;

    /**
     * labelCode
     */
    private String labelCode;

    private Long useInventoryUserId;

    private Long storageInventoryInoutId;







    /**
     * sku 名称
     */
    @ExcelExport(value = "物料名称",sort = 2)
    private String skuName;

    /**
     * sku 规格
     */
    @ExcelExport(value = "规格码",sort = 5)
    private String skuSpec;

    /**
     * sku 图片
     */
    private String skuPic;
    @ExcelExport(value = "产品图片",sort = 1)
    private URL skuPicVo;

    /**
     * 产品名称
     */
    private String productName;

    /**
     * 产品类型名称
     */
    private String productTypeName;

    /**
     * 产品分类名称
     */
    private String productCategoryName;

    /**
     * 产品品牌
     */
    @ExcelExport(value = "品牌",sort = 6)
    private String productBrandName;

    /**
     * 产品型号
     */
    private String productModelName;

    /**
     * 适配机床
     */
    private String deviceName;

    /**
     * 市场价
     */
    private BigDecimal marketPrice;

    @ExcelExport(value = "原规格",sort = 4)
    private String skuSpecOld;

    private String skuCodeOld;

    private Long workOrderId;

    /**
     * 企业编码
     */
    private String enterpriseCode;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime inTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected LocalDateTime outTime;

    private Integer remainingTime;


    /**
     * 寿命单位  1：小时/ 2：次数
     */
    private UseInventoryKnife.LifeUnit lifeUnit;

    private UseInventoryKnife.BusinessType businessType;

    private Integer lifeSpan;

    private ProductDetail.LifeUnit skuLifeUnit;

    public String getSkuLifeUnitDesc(){
        if (skuLifeUnit!=null){
            return skuLifeUnit.getDesc();
        }
        return "";
    }

    private Boolean lifeFlag;

    private Integer settingTime;

    private String lifeUnitDesc;

    public String getLifeUnitDesc(){
        if (this.lifeUnit!=null){
            return this.lifeUnit.getDesc();
        }
        return "";
    }
    private Long processId;

    private String parentLabelCode;

    private Integer quantityParentLabel;

    @Override
    public int compareTo(UseInventoryKnifeVO o) {
        if (o.getLabelCode().contains("-")&&this.getLabelCode().contains("-")){
            return Integer.valueOf(o.getLabelCode().substring(o.getLabelCode().indexOf("-")+1))-Integer.valueOf(this.getLabelCode().substring(this.getLabelCode().indexOf("-")+1));
        }
        return 0;
    }

    private BigDecimal price;


    private List<UseInventoryKnifeVO> detailList;

    private String workOrderCode;

    private String remark;

    private String workshopName;

    private String packName;
    private Long packId;

}
